```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ajax技术详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #6B73FF 0%, #000DFF 100%);
            color: white;
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        .highlight {
            border-left: 4px solid #3B82F6;
            background-color: #F8FAFC;
        }
        .first-letter {
            font-size: 3em;
            line-height: 0.8;
            float: left;
            margin-right: 8px;
            color: #3B82F6;
            font-weight: bold;
        }
        .nav-item {
            position: relative;
        }
        .nav-item::after {
            content: '';
            position: absolute;
            bottom: -2px;
            left: 0;
            width: 0;
            height: 2px;
            background-color: #3B82F6;
            transition: width 0.3s;
        }
        .nav-item:hover::after {
            width: 100%;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">Ajax技术详解</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto">异步JavaScript和XML：创建更快、更流畅的Web体验</p>
            <div class="flex justify-center space-x-4">
                <a href="#intro" class="bg-white text-blue-600 px-6 py-2 rounded-full font-medium hover:bg-gray-100 transition">开始探索</a>
                <a href="#application" class="border-2 border-white text-white px-6 py-2 rounded-full font-medium hover:bg-white hover:text-blue-600 transition">应用场景</a>
            </div>
        </div>
    </section>

    <!-- Navigation -->
    <nav class="sticky top-0 bg-white shadow-sm z-10">
        <div class="container mx-auto max-w-5xl">
            <div class="flex justify-center space-x-8 py-4">
                <a href="#intro" class="nav-item px-2 py-1 text-gray-700 hover:text-blue-600">技术概述</a>
                <a href="#application" class="nav-item px-2 py-1 text-gray-700 hover:text-blue-600">应用场景</a>
                <a href="#model" class="nav-item px-2 py-1 text-gray-700 hover:text-blue-600">交互模型</a>
                <a href="#key-points" class="nav-item px-2 py-1 text-gray-700 hover:text-blue-600">关键技术</a>
                <a href="#case" class="nav-item px-2 py-1 text-gray-700 hover:text-blue-600">实战案例</a>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl py-12 px-4 md:px-0">
        <!-- Introduction Section -->
        <section id="intro" class="mb-20">
            <div class="flex items-center mb-8">
                <i class="fas fa-code text-blue-500 text-2xl mr-3"></i>
                <h2 class="text-3xl font-bold text-gray-800">技术概述</h2>
            </div>
            
            <div class="bg-white rounded-xl p-6 card">
                <div class="flex flex-col md:flex-row">
                    <div class="md:w-1/3 mb-6 md:mb-0 md:pr-6">
                        <img src="https://cdn.nlark.com/yuque/0/2023/jpeg/21449790/1692788921101-d21817dd-d1f1-4361-a12f-d5e037da388c.jpeg" alt="Ajax技术" class="rounded-lg w-full h-auto">
                    </div>
                    <div class="md:w-2/3">
                        <p><span class="first-letter">A</span>jax（Asynchronous JavaScript And XML）指异步 JavaScript 及 XML <span class="text-red-500 font-medium">不是一种新的编程语言</span>，而是一种用于创建更好更快以及交互性更强的 Web 应用程序的技术，是基于 JavaScript、XML、HTML、CSS 新用法。</p>
                        
                        <div class="mt-6 p-4 highlight rounded">
                            <h3 class="text-xl font-semibold mb-3 text-blue-600">Ajax：只刷新局部页面的技术</h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fab fa-js text-yellow-400 mt-1 mr-2"></i>
                                    <span><strong>JavaScript：</strong>更新局部的网页</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-code text-blue-400 mt-1 mr-2"></i>
                                    <span><strong>XML：</strong>一般用于请求数据和响应数据的封装</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-exchange-alt text-purple-500 mt-1 mr-2"></i>
                                    <span class="text-red-500 font-medium"><strong>XMLHttpRequest对象：</strong>发送请求到服务器并获得返回结果</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fab fa-css3-alt text-blue-300 mt-1 mr-2"></i>
                                    <span><strong>CSS：</strong>美化页面样式</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-sync-alt text-green-500 mt-1 mr-2"></i>
                                    <span><strong>异步：</strong>发送请求后不等返回结果，由回调函数处理结果</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Application Section -->
        <section id="application" class="mb-20">
            <div class="flex items-center mb-8">
                <i class="fas fa-mobile-alt text-blue-500 text-2xl mr-3"></i>
                <h2 class="text-3xl font-bold text-gray-800">Ajax的应用</h2>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                <div class="bg-white rounded-xl p-6 card">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 p-2 rounded-full mr-3">
                            <i class="fas fa-search text-blue-500"></i>
                        </div>
                        <h3 class="text-xl font-semibold">搜索与地图</h3>
                    </div>
                    <p class="text-gray-600">实时搜索建议和地图数据加载是Ajax的典型应用，无需刷新页面即可获取最新结果。</p>
                </div>
                
                <div class="bg-white rounded-xl p-6 card">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 p-2 rounded-full mr-3">
                            <i class="fas fa-check-circle text-green-500"></i>
                        </div>
                        <h3 class="text-xl font-semibold">表单校验</h3>
                    </div>
                    <p class="text-gray-600">实时验证用户输入数据的有效性，如用户名是否已被占用，提高用户体验。</p>
                </div>
                
                <div class="bg-white rounded-xl p-6 card md:col-span-2">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 p-2 rounded-full mr-3">
                            <i class="fas fa-shopping-cart text-purple-500"></i>
                        </div>
                        <h3 class="text-xl font-semibold">购物车功能</h3>
                    </div>
                    <p class="text-gray-600">电商网站中通过Ajax实现购物车商品的增删改查，局部刷新页面保持用户购物体验的流畅性。</p>
                </div>
            </div>
        </section>

        <!-- Interaction Model Section -->
        <section id="model" class="mb-20">
            <div class="flex items-center mb-8">
                <i class="fas fa-project-diagram text-blue-500 text-2xl mr-3"></i>
                <h2 class="text-3xl font-bold text-gray-800">Ajax交互模型</h2>
            </div>
            
            <div class="bg-white rounded-xl p-6 card">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-center">传统的Web交互方式</h3>
                        <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692788921392-0a406c55-54d1-4bcd-8e4b-9ffecb7ba99e.png" alt="传统交互" class="w-full h-auto rounded-lg">
                        <div class="mt-4 p-4 bg-gray-50 rounded-lg">
                            <ul class="list-disc pl-5 space-y-2">
                                <li>同步请求，页面整体刷新</li>
                                <li>用户体验不连贯</li>
                                <li>服务器负载较大</li>
                            </ul>
                        </div>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-center">Ajax的交互方式</h3>
                        <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692788921866-a4066bee-84f7-4303-9e8a-9043d782bcc4.png" alt="Ajax交互" class="w-full h-auto rounded-lg">
                        <div class="mt-4 p-4 bg-blue-50 rounded-lg">
                            <ul class="list-disc pl-5 space-y-2">
                                <li>异步请求，局部刷新</li>
                                <li>用户体验流畅</li>
                                <li>减轻服务器负担</li>
                                <li>减少带宽消耗</li>
                            </ul>
                        </div>
                    </div>
                </div>
                
                <div class="mt-8">
                    <div class="mermaid">
                        graph TD
                            A[用户界面] -->|用户操作| B[XMLHttpRequest创建]
                            B --> C[发送请求到服务器]
                            C --> D[服务器处理请求]
                            D --> E[返回数据给浏览器]
                            E --> F[更新页面局部内容]
                            F --> A
                    </div>
                </div>
            </div>
        </section>

        <!-- Key Points Section -->
        <section id="key-points" class="mb-20">
            <div class="flex items-center mb-8">
                <i class="fas fa-key text-blue-500 text-2xl mr-3"></i>
                <h2 class="text-3xl font-bold text-gray-800">Ajax关键技术点</h2>
            </div>
            
            <div class="space-y-8">
                <!-- XMLHttpRequest Object -->
                <div class="bg-white rounded-xl p-6 card">
                    <h3 class="text-2xl font-semibold mb-4 text-blue-600">XMLHttpRequest对象</h3>
                    <div class="mb-6">
                        <h4 class="text-lg font-medium mb-2">1. XMLHttpRequest 对象</h4>
                        <ol class="list-decimal pl-6 space-y-2">
                            <li>所有现代浏览器均支持 XMLHttpRequest 对象（IE5 和 IE6 使用 ActiveXObject）。</li>
                            <li>XMLHttpRequest 用于在后台与服务器交换数据。这意味着可以在不重新加载整个网页的情况下，对网页的某部分进行更新。</li>
                        </ol>
                    </div>
                    
                    <div class="mb-6">
                        <h4 class="text-lg font-medium mb-2">2. 创建 XMLHttpRequest 对象</h4>
                        <ol class="list-decimal pl-6 space-y-2">
                            <li>所有现代浏览器（IE7+、Firefox、Chrome、Safari 以及 Opera）均内建 XMLHttpRequest 对象。</li>
                        </ol>
                    </div>
                    
                    <div class="mb-6">
                        <h4 class="text-lg font-medium mb-2">3. 创建 XMLHttpRequest 对象的语法：</h4>
                        <ol class="list-decimal pl-6 space-y-2">
                            <li>variable=new XMLHttpRequest();</li>
                            <li>老版本的 Internet Explorer （IE5 和 IE6）使用 ActiveX 对象：</li>
                            <li>variable=new ActiveXObject("Microsoft.XMLHTTP");</li>
                        </ol>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-medium mb-2">4. 编写一个方法兼容各个主流浏览器：</h4>
                        <img src="https://cdn.nlark.com/yuque/0/2023/png/21449790/1692788922140-5e0abcd4-9c17-4d5d-9145-4e464146a1a9.png" alt="兼容代码" class="w-full max-w-lg h-auto rounded-lg border border-gray-200">
                    </div>
                </div>
                
                <!-- Data Exchange -->
                <div class="bg-white rounded-xl p-6 card">
                    <h3 class="text-2xl font-semibold mb-4 text-blue-600">XMLHttpRequest对象和服务器交换数据</h3>
                    <div class="mb-6">
                        <h4 class="text-lg font-medium mb-2">1. 向服务器发送请求</h4>
                        <ol class="list-decimal pl-6 space-y-2">
                            <li>如需将请求发送到服务器，我们使用 XMLHttpRequest 对象的 open() 和 send() 方法：</li>
                            <li>open(method,url,async)</li>
                            <li>xmlhttp.open("GET","url",true);</li>
                            <li>send(string) string：仅用于 POST 请求</li>
                            <li>xmlhttp.send();</li>
                        </ol>
                    </div>
                </div>
                
                <!-- onreadystatechange Event -->
                <div class="bg-white rounded-xl p-6 card">
                    <h3 class="text-2xl font-semibold mb-4 text-blue-600">onreadystatechange 事件</h3>
                    <p class="mb-4">当请求被发送到服务器时，我们需要执行一些基于响应的任务。<strong>每当 readyState 改变时，就会触发 onreadystatechange 事件</strong>。readyState 属性存有 XMLHttpRequest 的状态信息。下面是 XMLHttpRequest 对象的三个重要的属性：</p>
                    <p>如需获得来自服务器的响应，请使用 XMLHttpRequest 对象的 responseText 或 responseXML 属性。</p>
                    
                    <div class="mt-6 bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-semibold mb-2">状态码说明：</h4>
                        <ul class="space-y-2">
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded mr-2">0</span>
                                <span>请求未初始化</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded mr-2">1</span>
                                <span>服务器连接已建立</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded mr-2">2</span>
                                <span>请求已接收</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded mr-2">3</span>
                                <span>请求处理中</span>
                            </li>
                            <li class="flex items-start">
                                <span class="bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded mr-2">4</span>
                                <span>请求已完成，且响应已就绪</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Case Studies Section -->
        <section id="case" class="mb-20">
            <div class="flex items-center mb-8">
                <i class="fas fa-laptop-code text-blue-500 text-2xl mr-3"></i>
                <h2 class="text-3xl font-bold text-gray-800">Ajax案例实战</h2>
            </div>
            
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                <!-- Case 1 -->
                <div class="bg-white rounded-xl p-6 card">
                    <h3 class="text-2xl font-semibold mb-4 text-blue-600">验证用户名的唯一性</h3>
                    <ol class="list-decimal pl-6 space-y-3">
                        <li><strong>准备好测试的环境</strong>
                            <ul class="list-disc pl-6 mt-1 space-y-1">
                                <li>创建表单页面，一个用户名，一个手机号</li>
                                <li>为用户名文本框绑定失去焦点事件</li>
                                <li>当触发焦点事件时，发送ajax异步请求，判断用户名的唯一性</li>
                            </ul>
                        </li>
                        <li><strong>掌握ajax发送异步请求的步骤</strong></li>
                        <li><strong>编写好后端的Servlet处理请求</strong></li>
                    </ol>
                    
                    <div class="mt-6 bg-gray-100 p-4 rounded-lg">
                        <h4 class="font-semibold mb-2">核心代码示例：</h4>
                        <pre class="bg-gray-800 text-gray-100 p-3 rounded text-sm overflow-x-auto">
// JavaScript部分
document.getElementById('username').addEventListener('blur', function() {
    var xhr = new XMLHttpRequest();
    xhr.open('POST', '/checkUsername', true);
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4 && xhr.status == 200) {
            var response = JSON.parse(xhr.responseText);
            if (response.available) {
                // 用户名可用
            } else {
                // 用户名已存在
            }
        }
    };
    xhr.send('username=' + encodeURIComponent(this.value));
});</pre>
                    </div>
                </div>
                
                <!-- Case 2 -->
                <div class="bg-white rounded-xl p-6 card">
                    <h3 class="text-2xl font-semibold mb-4 text-blue-600">级联效果</h3>
                    <p class="mb-4">通过选择省从而关联出城市的数据。</p>
                    
                    <div class="border border-gray-200 rounded-lg p-4">
                        <div class="flex space-x-4 mb-4">
                            <div class="w-1/2">
                                <label class="block text-sm font-medium text-gray-700 mb-1">省份</label>
                                <select class="w-full border border-gray-300 rounded-md px-3 py-2">
                                    <option value="">请选择省份</option>
                                    <option value="1">北京市</option>
                                    <option value="2">上海市</option>
                                    <option value="3">广东省</option>
                                </select>
                            </div>
                            <div class="w-1/2">
                                <label class="block text-sm font-medium text-gray-700 mb-1">城市</label>
                                <select class="w-full border border-gray-300 rounded-md px-3 py-2" disabled>
                                    <option value="">请先选择省份</option>
                                </select>
                            </div>
                        </div>
                        <div class="text-xs text-gray-500">选择省份后，城市选项将通过Ajax动态加载</div>
                    </div>
                    
                    <div class="mt-6 bg-gray-100 p-4 rounded-lg">
                        <h4 class="font-semibold mb-2">实现思路：</h4>
                        <ol class="list-decimal pl-6 space-y-1">
                            <li>监听省份select的change事件</li>
                            <li>获取选中的省份ID</li>
                            <li>发送Ajax请求到服务器获取对应城市数据</li>
                            <li>动态生成城市select的option选项</li>
                            <li>启用城市select控件</li>
                        </ol>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-10">
        <div class="container mx-auto max-w-5xl px-4 text-center">
            <h3 class="text-xl font-semibold mb-2">技术小馆</h3>
            <p class="mb-4">探索技术世界，分享知识精华</p>
            <a href="http://www.yuque.com/jtostring" class="text-blue-300 hover:text-white transition">http://www.yuque.com/jtostring</a>
            <div class="mt-6 flex justify-center space-x-4">
                <a href="#" class="hover:text-blue-300 transition"><i class="fab fa-github text-xl"></i></a>
                <a href="#" class="hover:text-blue-300 transition"><i class="fab fa-weixin text-xl"></i></a>
                <a href="#" class="hover:text-blue-300 transition"><i class="fab fa-qq text-xl"></i></a>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true
            }
        });
        
        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```